/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vista;

import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.jasperreports.engine.JRException;
import reportes.Reporte;

/**
 *
 * @author USUARIO WINDOWS
 */
public class vistaReportes extends javax.swing.JFrame {

    /**
     * Creates new form vistaReportes
     */
    public vistaReportes() {
        initComponents();
        reporte = new Reporte();
        setLocation(500, 200);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jBGenerarReporte = new javax.swing.JButton();
        boxReportes = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Reportes");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jBGenerarReporte.setText("Generar");
        jBGenerarReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBGenerarReporteActionPerformed(evt);
            }
        });
        getContentPane().add(jBGenerarReporte, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 130, 150, -1));

        boxReportes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Reporte Productos Más Vendidos","Reporte Productos Más Rentables","Reporte Proveedores Más Rentables","Reporte Compras","Reporte Productos en promoción"," Inventario de porductos","Reporte de Ventas"}));
        getContentPane().add(boxReportes, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 260, 30));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBGenerarReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBGenerarReporteActionPerformed
        // TODO add your handling code here:
        if (boxReportes.getSelectedIndex() == 0) {
            try {
                reporte.generarReporteProdMasVendidos();
            } catch (JRException ex) {
                Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            if (boxReportes.getSelectedIndex() == 1) {
                try {
                    reporte.generarReporteProdMasRentable();
                } catch (JRException ex) {
                    Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        
        else{
                if(boxReportes.getSelectedIndex() == 2){
                    try {
                        reporte.generarReporteProveedorMasRentable();
                    } catch (JRException ex) {
                        Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                
            
    
        else {
                if(boxReportes.getSelectedIndex()==3){
                    try {
                        reporte.generarReporteCompra();
                    } catch (JRException ex) {
                        Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
                
            else {
                    if(boxReportes.getSelectedIndex()==4){
                        try {
                            reporte.generarReporteProductosPromocion();
                        } catch (JRException ex) {
                            Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
                        }
        }
                    else{
                        if(boxReportes.getSelectedIndex()==5){
                            try {
                                reporte.generarInventarioProductos();
                            } catch (JRException ex) {
                                Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
                            }
                        }
                        else {
                            if (boxReportes.getSelectedIndex()==6){
                                try {
                                    reporte.generarReporteVenta();
                                } catch (JRException ex) {
                                    Logger.getLogger(vistaReportes.class.getName()).log(Level.SEVERE, null, ex);
                                }
                                
                            }
                        }
                    }
                
                
                }
                }
            }
        }
    }//GEN-LAST:event_jBGenerarReporteActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;

                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(vistaReportes.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(vistaReportes.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(vistaReportes.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(vistaReportes.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new vistaReportes().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox boxReportes;
    private javax.swing.JButton jBGenerarReporte;
    // End of variables declaration//GEN-END:variables
    private Reporte reporte;
}
